﻿define(['util', 'ajax'], function (util, ajax) {
    "use strict";

    var exports = {},
         ViewModel;    

    ViewModel = function (model) {
        var data = model.detail;
        var self = this;

        var canvas = document.getElementById("imgCanvas");
        util.image.drawImage(canvas, util.image.checkOrDefault(data.imageData));
        
        self.id = ko.observable(data.id);
        self.name = ko.observable(data.name);
        self.titleName = ko.observable(data.nameTitle);
        self.firstName = ko.observable(data.firstName);
        self.lastName = ko.observable(data.lastName);
        self.email = ko.observable(data.email);
        self.phone = ko.observable(data.phone);
        self.mobile = ko.observable(data.mobile);
        self.CompanyName = ko.observable(data.companyName);
        self.designation = ko.observable(data.designation);
        self.description = ko.observable(data.description);
        self.imageData = ko.observable(data.imageData);                
    };

    exports.exec = function (sectionId, model) {
        var viewModel = new ViewModel(model);
        ko.applyBindings(viewModel, document.getElementById(sectionId));
    };

    return exports;
});